package com.glsc.ngateway.common.base.domain.mysql.gateway.platform.webfield;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * @author zhengyr
 * @date 2024/1/29-12:47
 * 流程类表单属性配置-主表
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@Entity
@Where(clause = "deleted = 0")
@SQLDelete(sql = "update t_gw_flow_form_web_field set deleted = UNIX_TIMESTAMP(NOW()) where id=?")
@SQLDeleteAll(sql = "update t_gw_flow_form_web_field set deleted = UNIX_TIMESTAMP(NOW()) where id=?")
@Table(name = "t_gw_flow_form_web_field", indexes = {@Index(name = "UK_HOST", columnList = "process_defineKey, deleted", unique = true)})
public class FlowFormWebField implements Serializable {

    @ApiModelProperty(value = "id")
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;

    @ApiModelProperty(value = "代表页面类型的type+id组合")
    private String ident;

    @ApiModelProperty(value = "是否需要新建父级路由")
    @Column(name = "is_parent_create", columnDefinition = "char(1) NOT NULL COMMENT '是否需要新建父级路由'")
    private String isParentCreate;

    @ApiModelProperty(value = "父级路由菜单权限--path")
    @Column(name = "router_location", columnDefinition = "VARCHAR(200) NOT NULL COMMENT '父级路由菜单权限--path'")
    @Builder.Default
    private String routerLocation="root";

    @ApiModelProperty(value = "流程中文名")
    @Column(name = "flow_name", columnDefinition = "VARCHAR(50) NOT NULL COMMENT '流程中文名'")
    private String flowName;

    @ApiModelProperty(value = "流程类型key")
    @Column(name = "process_defineKey", columnDefinition = "VARCHAR(50) NOT NULL COMMENT '流程类型key'")
    private String processDefineKey;

    @ApiModelProperty(value = "流程通用接口前缀")
    @Column(name = "page_api", columnDefinition = "VARCHAR(64) NOT NULL COMMENT '流程通用接口前缀'")
    private String pageApi;

//    @ApiModelProperty(value = "发起节点是否需要初始化附件类型")
//    @Column(name = "is_init_file_list", columnDefinition = "char(1) COMMENT '发起节点是否需要初始化附件类型'")
//    private String isInitFileList;

    @Builder.Default
    @Column(name = "deleted", columnDefinition = "bigint NOT NULL default 0")
    private Long deleted = 0L;

    @Transient
    @ApiModelProperty(value = "字段配置列表")
    private List<WebFieldItem> fieldList;
}
